import { fileURLToPath, URL } from 'node:url'
import Path from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import VueSetupExtend from 'vite-plugin-vue-setup-extend'

import Components from 'unplugin-vue-components/vite'
// const path = require('path')
// const rootpath = path.resolve(__dirname,'./src')
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    VueSetupExtend(),
    Components({
      dirs: ['src/components'],
      extensions: ['vue'],
      dts: false
    })
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  css: {
    preprocessorOptions: {
      less: {
        modifyVars: {
          hack: `
           true; @import (reference) "${Path.resolve(
             __dirname,
             'src/styles/mixins.less'
           )}"`,
          hack2: `
           true; @import (reference) "${Path.resolve(
             __dirname,
             'src/styles/variables.less'
           )}"`
        }
      }
    }
  }
})
